2wirespiiso 2.2.0
Loading...
Searching...
No Matches
main.c File Reference

2-Wire SPI ISO Click example More...

#include "board.h"
#include "log.h"
#include "c2wirespiiso.h"

Macros

#define TIMEOUT_MS   1000
#define DEVICE_NAME   "Accel 22 Click"
#define DEVICE_SPI_READ_REG   0x0B
#define DEVICE_REG_ID   0x00
#define DEVICE_ID   0xAD

Functions

void c2wirespiiso_get_accel22_id (c2wirespiiso_t *ctx)
 2-Wire SPI ISO get Accel 22 ID function.
void application_init (void)
void application_task (void)
int main (void)

Detailed Description

2-Wire SPI ISO Click example

Description

This example demonstrates the use of a 2-Wire SPI ISO Click board by showing the communication between the two Click boards (Slave and Master). That is performed by sending commands to a 2-Wire SPI ISO Click (Slave) to read the device ID of a Accel 22 Click board connected to the 2-Wire SPI ISO Click (Master).

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.

Application Task

Reads and checks the device ID of a Accel 22 Click board connected to the 2-Wire SPI ISO (Master) Click, and displays the results on the USB UART approximately once per second.

Note
The communication topology is as follows: MCU <-> 2-Wire SPI ISO Click (Slave) <-> 2-Wire SPI ISO Click (Master) <-> Accel 22 Click The Master/Slave selection is done via on-board SMD jumpers. The Master Click board must be powered up with a 3V3 and 5V power supply externally. Also the DIS must be pulled down on Master Click board to enable the device.
Author
Stefan Filipovic

Macro Definition Documentation

◆ DEVICE_ID

#define DEVICE_ID   0xAD

◆ DEVICE_NAME

#define DEVICE_NAME   "Accel 22 Click"

◆ DEVICE_REG_ID

#define DEVICE_REG_ID   0x00

◆ DEVICE_SPI_READ_REG

#define DEVICE_SPI_READ_REG   0x0B

◆ TIMEOUT_MS

#define TIMEOUT_MS   1000

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ c2wirespiiso_get_accel22_id()

void c2wirespiiso_get_accel22_id ( c2wirespiiso_t * ctx)

2-Wire SPI ISO get Accel 22 ID function.

This function reads and checks the device ID of the Accel 22 Click board which is connected to 2-Wire SPI ISO (master) Click board.

Parameters
[in]ctx: Click context object. See #spiisolator6_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ main()

int main ( void )